package com.mfl.controller.admin;

import com.mfl.common.PageResult;
import com.mfl.common.Result;
import com.mfl.pojo.dto.TestExamDTO;
import com.mfl.pojo.dto.TestExamPageQueryDTO;
import com.mfl.service.TestExamService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController("adminTestExamController")
@RequestMapping("/cky/admin/testExam")
@Slf4j
public class TestExamController {

    @Autowired
    private TestExamService testExamService;

    /**
     * 分页查询测试试卷
     * @param testExamPageQueryDTO
     * @return
     */
    @GetMapping("/page")
    public Result<PageResult> page(TestExamPageQueryDTO testExamPageQueryDTO){
        log.info("分页查询测试试卷：{}", testExamPageQueryDTO);
        PageResult pageResult = testExamService.pageQuery(testExamPageQueryDTO);
        return Result.success("", pageResult);
    }

    /**
     * 添加测试卷
     * @param testExamDTO
     * @return
     */
    @PostMapping("/insert")
    public Result insert(@RequestBody TestExamDTO testExamDTO){
        log.info("添加测试卷：{}", testExamDTO);
        testExamService.insert(testExamDTO);
        return Result.success("添加成功");
    }

    /**
     * 批量删除测试试卷
     * @param ids
     * @return
     */
    @DeleteMapping("/batchDelete")
    public Result batchDelete(@RequestParam List<Integer> ids){
        log.info("批量删除测试试卷：{}", ids);
        testExamService.batchDelete(ids);
        return Result.success("删除成功");
    }
}
